package com.guigu.www.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.guigu.www.pojo.HealthManager;
import com.guigu.www.mapper.HealthManagerMapper;
import com.guigu.www.service.HealthManagerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PutMapping;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author DengHao
 * @since 2021-10-20
 */
@Service
public class HealthManagerServiceImpl implements HealthManagerService {

    @Autowired
    private HealthManagerMapper healthManagerMapper;

    @Override
    public HealthManager login(String hmUsername, String hmPassword) {
        QueryWrapper<HealthManager> wrapper = new QueryWrapper<>();
        wrapper.eq("hm_username",hmUsername).eq("hm_password",hmPassword);
        return healthManagerMapper.selectOne(wrapper);
    }

    // 验证号码的方法
    @Override
    public HealthManager queryPhone(String hmPhone) {
        return healthManagerMapper.selectOne(new QueryWrapper<HealthManager>().eq("hm_phone",hmPhone));
    }

    @Override
    public Integer upPasswordMethod(Integer hmId, String pass) {
        HealthManager healthManager = new HealthManager();
        healthManager.setHmId(hmId);
        healthManager.setHmPassword(pass);
        return healthManagerMapper.updateById(healthManager);
    }


}
